package com.gdust.hzx.manager.service.impl;

import com.gdust.hzx.manager.mapper.BrandMapper;
import com.gdust.hzx.manager.service.BrandService;
import com.gdust.hzx.model.entity.product.Brand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: BrandServiceImpl
 * Package: com.gdust.spzx.manager.service.impl
 * Description:品牌类服务层实现类
 *
 * @Author syun
 * @Create 2024/12/1 22:14
 * @Version 1.0
 */
@Service
public class BrandServiceImpl implements BrandService {
    //注入分类品牌表的mapper
    @Autowired
    private BrandMapper brandMapper;

    /**
     * 使用pagehelper分页插件进行分页
     * 分页查询品牌
     * @param page 当前页
     * @param limit 每页记录数
     * @return
     */
    @Override
    public PageInfo<Brand> findPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Brand> list= brandMapper.findPage();
        PageInfo<Brand> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 品牌添加
     * @param brand
     */
    @Override
    public void save(Brand brand) {
        //自定义查询：品牌添加
        brandMapper.save(brand);

    }

    /**
     * 根据id修改品牌
     * @param brand 品牌类
     */
    @Override
    public void updateById(Brand brand) {
        //自定义查询：根据id修改品牌
        brandMapper.updateById(brand);
    }

    /**
     * 删除指定品牌
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        //自定义查询：根据id删除品牌
        brandMapper.deleteById(id);
    }

    /**
     * 列表查询接口
     * @return
     */
    @Override
    public List<Brand> findAll() {
        //自定义查询：列表查询
        return brandMapper.findAll();
    }
}
